{extend name="public/base"}
{block name="main"}
<div id="main" class="container">
    <div class="text-right">
        <button class="btn btn-info"><a href="{:url('article/create')}">添加文章</a> </button>
    </div>
    <div  >
        <table class="table">
            <caption>文章列表</caption>
            <thead>
            <tr>
                <th>title</th>
                <th>category</th>
                <th>author</th>
                <th>click</th>
                <th>add_at</th>
                <th>update_at</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list.list" id="vo"}
            <tr>
                <td>{$vo.title}</td>
                <td>{$vo.c_name}</td>
                <td>{$vo.author}</td>
                <td>{$vo.click}</td>
                <td>{$vo.add_at|date="Y-m-d H:i:s"}</td>
                <td>{$vo.update_at|date="Y-m-d H:i:s"}</td>
                <td><button class="btn btn-default"  @click="edit({$vo.id})" >修改</button> <button class="btn btn-info"  @click="callback({$vo.id})" >回收</button> <button class="btn btn-danger" @click="del({$vo.id})">删除</button></td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div>{$list.page|raw}</div>
    </div>
</div>
<script>
    var data ={};
    new Vue({
        el:"#main",
        data:data,
        methods:{
            edit:function(id){
                window.location.href="{:url('article/create')}?id="+id;
            },
            del:function(id){
                if(confirm("确定要删除文章么")){
                    var url = "{:url('article/delete')}";
                    var data = {'id':id};
                    ajax(url,data,'GET',function(re){
                        if(re.status == 1){
                            window.location.reload();
                        }
                    });
                };
            },
            callback:function(id){
                var url = "{:url('article/callback')}";
                var datas = {'id':id};
                ajax(url,datas,'get',function(re){
                    if(re.status == 1){
                        window.location.reload();
                    }
                });
            }

        }
    })
</script>

{/block}